﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
/**
* @Author: AdinZ
* @Q  Q : 1454269
* @Email:adinz@adinz.com
* @Created: 2014/4/7 8:15:13
* */
namespace Web.plug
{
    /// <summary>
    /// login 的摘要说明
    /// </summary>
    public class login : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            Novel.Sys.BLL.novel_user bll = new Novel.Sys.BLL.novel_user();
            Novel.Sys.Model.novel_user model = new Novel.Sys.Model.novel_user();
            context.Response.ContentType = "text/plain";
            string name = context.Request["name"];
            string passwd = context.Request["passwd"];
            string cb = context.Request["cbSave"];
            string resurl = context.Request["resurl"];
            if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(passwd))
            {
                bool check = false ;
                if (!string.IsNullOrEmpty(cb))
                {
                    if (cb.Equals("on")) { check = true; }
                }
               if( bll.Exists(name,AdinZ.Common.EncryAndDecry.EncryMd5(passwd,true,true)))
               {
                   context.Response.Write("1");

                  model= bll.GetModel(name);
                  if (check)
                      Novel.Utils.CookieUtil.SaveCookie(model, 43200);
                  else
                      Novel.Utils.CookieUtil.SaveCookie(model, 0);
               }
               else
               {
                   context.Response.Write("0");
               }

            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}